﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QLNHang.BUS;

namespace QLNHang.GUI
{
   
    public partial class ucCapNhatNguyenVatLieu : UserControl
    {
        private int maNguyenLieu;
        private int index;
        public ucCapNhatNguyenVatLieu()
        {
            InitializeComponent();
        }

        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            NguyenLieuBUS nl = new NguyenLieuBUS();
            int soLuong = int.Parse(txtSoLuong.Text);
         
            dgvNguyenLieu.Rows[index].Cells[3].Value = soLuong;
            nl.CapNhatSoLuong(maNguyenLieu, soLuong);
        }

        private void ucCapNhatNguyenVatLieu_Load(object sender, EventArgs e)
        {
            NguyenLieuBUS nl = new NguyenLieuBUS();
            DataTable dt = nl.LayNguyenLieu();
            dgvNguyenLieu.DataSource = dt;
        }

        private void dgvNguyenLieu_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
          
        }

        private void dgvNguyenLieu_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            txtTenNguyenLieu.Text = dgvNguyenLieu.Rows[e.RowIndex].Cells[1].Value.ToString();
            txtSoLuong.Text = dgvNguyenLieu.Rows[e.RowIndex].Cells[3].Value.ToString();
            index = e.RowIndex;
            maNguyenLieu = int.Parse(dgvNguyenLieu.Rows[e.RowIndex].Cells[0].Value.ToString());
        }


   
    }
}
